<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>小草的音乐库</title>
    <style>
      * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
      }
      body {
        font-family: 'Microsoft YaHei', Arial, sans-serif;
        background-color: white;
        color: #333;
        min-height: 100vh;
        padding-top: 60px;
      }
      .playlist-button {
        position: fixed;
        top: 20px;
        left: 20px;
        padding: 10px 20px;
        background-color: #f8f8f8;
        border: 1px solid #ddd;
        border-radius: 5px;
        cursor: pointer;
        font-size: 16px;
        transition: all 0.3s ease;
        z-index: 1000;
      }
      .playlist-button:hover {
        background-color: #e8e8e8;
      }
      .playlist-modal {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 2000;
        justify-content: center;
        align-items: center;
      }
      .modal-content {
        background-color: white;
        padding: 30px;
        border-radius: 10px;
        width: 80%;
        max-width: 500px;
        max-height: 80vh;
        overflow-y: auto;
      }
      .modal-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 20px;
        padding-bottom: 10px;
        border-bottom: 1px solid #eee;
      }
      .modal-title {
        font-size: 20px;
        font-weight: bold;
      }
      .close-button {
        background: none;
        border: none;
        font-size: 24px;
        cursor: pointer;
        color: #999;
      }
      .modal-body {
        font-size: 16px;
      }
      .welcome-container {
        text-align: center;
        margin-bottom: 30px;
      }
      .welcome-text {
        font-family: "STKaiti", "KaiTi", serif;
        font-size: 48px;
        color: #a98fd7;
        margin: 0;
        text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
      }
      .search-container {
        width: 100%;
        max-width: 600px;
        margin: 0 auto;
        position: relative;
      }
      .search-bar {
        width: 100%;
        padding: 15px 20px;
        font-size: 18px;
        border: 2px solid #c3e0f5;
        border-radius: 30px;
        background-color: #e8f4fd;
        transition: all 0.3s ease;
      }
      .search-bar:focus {
        outline: none;
        border-color: #91c3e8;
        background-color: white;
        box-shadow: 0 0 10px rgba(145, 195, 232, 0.3);
      }
      .suggestions {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background-color: white;
        border: 1px solid #ddd;
        border-radius: 0 0 10px 10px;
        box-shadow: 0 5px 15px rgba(0,0,0,0.1);
        max-height: 300px;
        overflow-y: auto;
        z-index: 100;
      }
      .suggestion-item {
        padding: 12px 20px;
        cursor: pointer;
        transition: all 0.2s ease;
        font-size: 16px;
      }
      .suggestion-item:hover {
        background-color: #f5f5f5;
        color: #ff0000;
      }
    </style>
  </head>
  <body>
    <!-- 歌单按钮 -->
    <button class="playlist-button" id="playlistButton">歌单</button>
    
    <!-- 歌单弹窗 -->
    <div class="playlist-modal" id="playlistModal">
      <div class="modal-content">
        <div class="modal-header">
          <h2 class="modal-title">歌单列表</h2>
          <button class="close-button" id="closeModal">&times;</button>
        </div>
        <div class="modal-body" id="playlistContent">
          <!-- 歌单内容将通过JavaScript加载 -->
        </div>
      </div>
    </div>
    
    <!-- 欢迎文字 -->
    <div class="welcome-container">
      <h1 class="welcome-text">欢迎使用小草的音乐库</h1>
    </div>
    
    <!-- 搜索栏 -->
    <div class="search-container">
      <input type="text" class="search-bar" id="searchInput" placeholder="搜索音乐...">
      <div class="suggestions" id="suggestionsContainer"></div>
    </div>
    
    <script>
      // 音乐库文件列表
      const musicFiles = ['下雨'];
      
      // 元素引用
      const playlistButton = document.getElementById('playlistButton');
      const playlistModal = document.getElementById('playlistModal');
      const closeModal = document.getElementById('closeModal');
      const playlistContent = document.getElementById('playlistContent');
      const searchInput = document.getElementById('searchInput');
      const suggestionsContainer = document.getElementById('suggestionsContainer');
      
      // 加载歌单内容
      function loadPlaylist() {
        // 由于我们无法直接读取本地文件，这里使用硬编码的方式
        // 实际项目中可以使用服务器API来获取歌单内容
        playlistContent.textContent = '下雨';
      }
      
      // 显示搜索联想
      function showSuggestions(query) {
        if (!query.trim()) {
          suggestionsContainer.style.display = 'none';
          return;
        }
        
        const filteredFiles = musicFiles.filter(file => 
          file.toLowerCase().includes(query.toLowerCase())
        );
        
        if (filteredFiles.length === 0) {
          suggestionsContainer.style.display = 'none';
          return;
        }
        
        suggestionsContainer.innerHTML = '';
        filteredFiles.forEach(file => {
          const item = document.createElement('div');
          item.className = 'suggestion-item';
          item.textContent = file;
          item.addEventListener('click', () => {
            // 打开对应的HTML文件
            window.location.href = `音乐库/${file}.html`;
          });
          suggestionsContainer.appendChild(item);
        });
        
        suggestionsContainer.style.display = 'block';
      }
      
      // 事件监听器
      playlistButton.addEventListener('click', () => {
        loadPlaylist();
        playlistModal.style.display = 'flex';
      });
      
      closeModal.addEventListener('click', () => {
        playlistModal.style.display = 'none';
      });
      
      // 点击模态框外部关闭
      window.addEventListener('click', (event) => {
        if (event.target === playlistModal) {
          playlistModal.style.display = 'none';
        }
      });
      
      // 搜索输入事件
      searchInput.addEventListener('input', (event) => {
        showSuggestions(event.target.value);
      });
      
      // 点击页面其他地方关闭搜索联想
      document.addEventListener('click', (event) => {
        if (!searchInput.contains(event.target) && !suggestionsContainer.contains(event.target)) {
          suggestionsContainer.style.display = 'none';
        }
      });
    </script>
  </body>
</html>